package com.jrtc.service.impl;

import com.jrtc.base.entity.bo.CatchBallRecord;
import com.jrtc.base.entity.bo.CatchBallRecordDetails;
import com.jrtc.base.entity.bo.DoctorRemark;
import com.jrtc.base.entity.bo.Patient;
import com.jrtc.base.entity.vo.CatchBallRecordVo;
import com.jrtc.dao.CatchBallRecordDao;
import com.jrtc.dao.CatchBallRecordDetailsDao;
import com.jrtc.dao.DoctorRemarkDao;
import com.jrtc.dao.PatientDao;
import com.jrtc.service.CatchBallRecordService;
import com.jrtc.service.DoctorRemarkService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.beans.SimpleBeanInfo;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.List;

@Service("doctorRemarkService")
public class DoctorRemarkServiceImpl implements DoctorRemarkService {
    @Resource
    private DoctorRemarkDao doctorRemarkDao;

    /**
     * 医生备注列表
     * */
    @Override
    public List<DoctorRemark> doctorRemarkList(Integer id, Integer tid) {
        SimpleDateFormat format = new SimpleDateFormat("YYYY-MM-dd HH:mm:ss");
        List<DoctorRemark> doctorRemarkList = doctorRemarkDao.doctorRemarkList(id, tid);
        if (doctorRemarkList != null && doctorRemarkList.size() > 0){
            for (DoctorRemark doctorRemark : doctorRemarkList) {
                if (doctorRemark != null){
                    if (doctorRemark.getCreateTime() != null){
                        doctorRemark.setCreateDate(format.format(doctorRemark.getCreateTime()));
                    }
                }
            }
        }
        return doctorRemarkList;
    }

    /**
     * 新增医生备注
     * */
    @Override
    public int insertRemark(String remark, Integer id, Integer patientId, String memo) {
        DoctorRemark doctorRemark = new DoctorRemark();
        doctorRemark.setRemarkName(remark);
        doctorRemark.setCreateTime(new Date());
        doctorRemark.setDoctorId(id);
        doctorRemark.setPatientId(patientId);
        doctorRemark.setMemo(memo);
        int i = doctorRemarkDao.insertRemark(doctorRemark);
        return i;
    }

    /**
     * 修改医生备注
     * @param doctorRemark
     * @return
     */
    @Override
    public int updateRemark(DoctorRemark doctorRemark) {
        return doctorRemarkDao.updateRemark(doctorRemark);
    }

    @Override
    public DoctorRemark queryRemarkById(Integer id) {
        return doctorRemarkDao.queryRemarkById(id);
    }
}